/**
 * File: ReadEntryReader.java
 * Created by: mhaimel
 * Created on: 18 Aug 2009
 * CVS:  $Id: ReadEntryReader.java,v 1.1 2009/08/27 14:52:44 mhaimel Exp $
 */
package uk.ac.ebi.curtain.util.io;

import java.io.BufferedReader;
import java.io.File;
import java.util.Iterator;

import uk.ac.ebi.velvet.model.Strand;

/**
 * @author mhaimel
 *
 */
public class ReadEntryReader extends AbstractReader<ReadEntryBean> {

	public ReadEntryReader(File in) {
		super(in);
	}

	/**
	 * {@inheritDoc}
	 */
	@Override
	protected Iterator<ReadEntryBean> _buildIter(File inFile) {
		return new ReadEntryIter(inFile);
	}
	
	public static class ReadEntryIter extends AbstractIter<ReadEntryBean>{

		public ReadEntryIter(File f, BufferedReader in) {
			super(f, in);
		}

		public ReadEntryIter(File f) {
			super(f);
		}

		/* FileId | Id | Strand | LocalFilePos */
		@Override
		protected ReadEntryBean _buildEntry(String[] arr) {
			ReadEntryBean bean = new ReadEntryBean();
			bean.setFileId(Integer.valueOf(arr[0]));
			bean.setId(arr[1]);
			bean.setStrand(Strand.getStrand(arr[2].charAt(0)));
			bean.setLocalFilePos(Long.valueOf(arr[3]));
			return bean;
		}
		
	}
}
